package com.zkingsoft.cmstags;

import java.io.IOException;
import java.io.StringWriter;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import com.zkingsoft.constance.SystemConstance;
import com.zkingsoft.model.bus.BusParameterSettings;
import com.zkingsoft.model.web.WebNav;
import com.zkingsoft.services.bus.BusParameterSettingsService;
import com.zkingsoft.services.web.WebNavService;
import com.zkingsoft.util.StringUtils;
import com.zkingsoft.util.WebUtil;

public class SettingTag extends SimpleTagSupport {

	/**
	 * 导航栏类型
	 */
	private String code;
	private Long companyId;

	/**
	 * 变量名称
	 */
	private String var;

	public String getVar() {
		return var;
	}

	public void setVar(String var) {
		this.var = var;
	}

	StringWriter sw = new StringWriter();

	/**
	 * 获取指定类型下的一级导航栏
	 * 
	 * @author jiangyouyao
	 */
	public void doTag() throws JspException, IOException {

		BusParameterSettingsService busParameterSettingsService = WebUtil.getService(this.getJspContext(),
				SystemConstance.SETTING_SERVICE);
		BusParameterSettings bs = new BusParameterSettings();
		bs.setCompanyId(companyId);
		bs.setParamCode(code);
		List<BusParameterSettings> bss = busParameterSettingsService.findByModel(bs);
		if (!bss.isEmpty()) {
			this.getJspContext().setAttribute(var, bss.get(0));
		}

	}

	public Long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	

}